package com.rentplant.controller;

import com.alibaba.fastjson.JSONObject;
import com.rentplant.Pojo.helpcollect;
import com.rentplant.Pojo.helpcollectanduser;
import com.rentplant.service.impl.helpCollectServiceImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@RestController
@RequestMapping("/helpCollect")
public class helpCollectController {
    @Autowired
    private helpCollectServiceImp helpcollectserviceimp;

    //    查询该用户是否收藏
    @RequestMapping("/isCollect")
    public List<helpcollect> isCollect(@RequestBody JSONObject req){
        try{
            return helpcollectserviceimp.isCollect(req);
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }

    //收藏求租信息
    @RequestMapping("/addHelpCollect")
    public boolean addHelpCollect(@RequestBody JSONObject req){
        try{
            return helpcollectserviceimp.addHelpCollect(req);
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }

    //取消求助收藏
    @RequestMapping("/delHelpCollect")
    public boolean delHelpCollect(@RequestBody JSONObject req){
        try{
            return helpcollectserviceimp.delHelpCollect(req);
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }

    //    展示用户收藏的求租信息
    @RequestMapping("/showHelpCollect")
    public List<helpcollectanduser>showHelpCollect(@RequestBody JSONObject req){
        try{
            return helpcollectserviceimp.showHelpCollect(req);
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }
}
